package com.znjc.device.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.znjc.common.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 【请填写功能名称】对象 device_point
 *
 * @author zengpc
 * @date 2023-12-04
 */
@Data
public class DevicePoint extends BaseZnjcEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 设备类别
     */
    @Excel(name = "设备类别")
    private Long typeId;
    /**
     * 设备类别名称
     */
    @Excel(name = "设备类别")
    @TableField(exist = false)
    private String typeName;
    /**
     * 测点名称
     */
    @Excel(name = "测点名称")
    private String pointName;

    /**
     * 测点编码
     */
    @Excel(name = "测点编码")
    private String pointCode;

    /**
     * 开始使用时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开始使用时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date startTime;

    /**
     * 设备图片地址
     */
    @Excel(name = "设备图片地址")
    private String imageUrl;

    /**
     * 设备地址
     */
    @Excel(name = "设备地址")
    private String address;

    /**
     * 是否显示 数据字典 is_show_data 0 是 1否
     */
    @Excel(name = "是否显示")
    private String isShowData;

    /**
     * 单位类别 数据字典 unit_type
     */
    @Excel(name = "单位类别")
    private String unitType;

    /**
     * 设备状态0正常1报警 数据字典 device_status
     */
    @Excel(name = "设备状态0正常1报警")
    private String deviceStatus;

    /**
     * 是否存在此串口标识 默认不存在
     */
    @TableField(exist = false)
    private boolean flag = false;

    public boolean isAdmin() {
        return isAdmin(this.getId());
    }

    public static boolean isAdmin(Long id) {
        return id != null && 1L == id;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("pointName", getPointName())
                .append("pointCode", getPointCode())
                .append("startTime", getStartTime())
                .append("imageUrl", getImageUrl())
                .append("address", getAddress())
                .append("isShowData", getIsShowData())
                .append("unitType", getUnitType())
                .append("deviceStatus", getDeviceStatus())
                .append("status", getStatus())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .append("deptId", getDeptId())
                .toString();
    }
}
